package com.etc.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.util.List;

/**
 * @Author kalista
 * @Description
 * @Date 2020/8/19  15:54
 **/
@RestController
public class OrderZkController {


    @Autowired
    private RestTemplate restTemplate;

    private static final String URL = "http://cloud-provider-paymentzk";

    @Autowired
    private DiscoveryClient discoveryClient;


    @GetMapping("/consumer/payment/zk")
    public String paymentinfo(){
        List<ServiceInstance> instances = discoveryClient.getInstances("cloud-provider-paymentzk");
        return restTemplate.getForObject(URL + "/payment/zk",String.class);
    }


}
